package com.longge;

import java.util.ArrayList;
import java.util.List;

public class preorderNTree {

    List<Integer> res = new ArrayList<>();
    public List<Integer> preorder(NTreeNode root) {

        if (root==null) return new ArrayList<>();
        res.add(root.val);
        for (NTreeNode child : root.children) {
            preorder(child);
        }
        return res;
    }
}
